<template>
  <aside class="author_top" style="height: 630px">
    <span class="title">作者推荐</span>
    <hr>

    <NoContent :show="modelValue.length == 0" text="暂无推荐人员"/>

    <div v-for="(att , index) in modelValue" :key="att.userId">
      <img class="avator"  :src="$api.preview(att.avatar)" />
      <span class="name">{{ att.nickName }}</span>
      <a class="attach" v-if="att.attention">已关注</a>
      <a class="at" @click="attention(att)" v-else>关注</a>
    </div>
  </aside>
</template>

<script setup>
import NoContent from "./NoContent.vue";
import API from '@/api/index.js' ;
import toastr from 'toastr' ;
import {useRouter} from 'vue-router' ;
import  {nextTick} from 'vue' ;
const { modelValue } = defineProps(["modelValue"]) ;

const router = useRouter() ;

function attention(att) {
  API.attentionUser(att.userId).then(ret => {
     if (ret.status) {
       toastr.success(ret.message) ;
       att.attention = !att.attention ;
     }
  })
}

</script>

<style scoped>
.aside .author_top .title {
  height: 40px;
  line-height: 40px;
  padding: 0 20px;
}

.aside .author_top div {
  height: 60px;
  line-height: 60px;
  padding: 0 20px;
  margin: 5px 0;
}

.aside .author_top .avator {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  float: left;
}

.aside .author_top  .name {
  float: left;
  line-height: 40px;
  padding: 0 5px;
  width: 170px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.aside .author_top .at, .aside .author_top .attach {
  width: 50px;
  height: 25px;
  text-align: center;
  line-height: 25px;
  font-size: 12px;
  border-radius: 5px;
  font-size: 12px;
  padding: 2px 10px;
  float: right;
  margin: 5px 0;
}

.aside .author_top .at {
	color: #777;
	background-color: #eee;
}

.aside .author_top .attach {
	background-color: #55aaff;
	color: #fff;
}

.aside .author_top .at:hover {
	background-color: #f3f3f3;
}

.aside .author_top .attach:hover {
	background-color: #55ccdd;
}

</style>